from flask import g, Blueprint, request, jsonify, render_template, session

from common import Result
from models import Classes, StudentClassesRel, TestPaper, Student, SignIn, TestPaperAnswer
from exts import db, get_time, to_json_all
from flask_login import login_required
from decorations import teacher_required

bp = Blueprint("api_teacher", __name__, url_prefix="/api/teacher")


# todo before_request
@bp.before_request
@login_required
@teacher_required
def before_request():
    pass


# todo /test_paper_1_to_2  # 老师收卷
@bp.route("/test_paper_1_to_2", methods=['POST'])
def test_paper_1_to_2():
    id_test_paper = request.values.get("id_test_paper")
    test_paper = db.session.query(TestPaper).get(id_test_paper)
    test_paper.state = 2

    db.session.commit()

    return Result.success(
        msg="收卷成功"
    )
